﻿<?php

$user_id = $_GET['id'];
$action = $_GET['action'];
$fav_id = $_GET['id'];

$username = $_POST['username'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$location = $_POST['location'];
$role = $_POST['role'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$email = $_POST['email'];
$website = $_POST['website'];

if(isset($user_id)&&($action=="view")) //επιλογή προβολής λεπτομερειών χρήστη
{
    include 'user_view.php';
}

if(isset($user_id)&&($action=="edit")){ //επιλογή edit χρήστη

     $query = "UPDATE USERS SET user_name = '".$username."', user_fname = '".$fname."', user_lname = '".$lname."', user_gender = '".$gender."',
     user_level = '".$role."',user_phone1 = '".$phone1."', user_phone2 = '".$phone2."', user_email = '".$email."', user_website = '".$website."'
     WHERE user_id = ".$user_id;

     $set->qry($query);

    include 'user_search.php';
    include 'user_results.php';
}

if(isset($user_id)&&($action=="delete")){ //επιλογή delete χρήστη

    $query = "DELETE FROM USERS WHERE user_id = ".$user_id;

    $set->qry($query);

    include 'user_search.php';
    include 'user_results.php';
}

if(isset($fav_id)&&($action=="delete_fav")){ //επιλογή delete αγγελίας απο τα favorite του χρήστη

    $query = "DELETE FROM FAVOURITES WHERE fav_id = ".$fav_id;

    $set->qry($query);

    include 'user_search.php';
    include 'user_results.php';
}

if($action=="new"){ //επιλογή νέου χρήστη

    include 'user_new.php';
}